ALMaSS  1.0
The Animal, Landscape and Man Simulation System
Partridge_Base Class Reference

Base class for all partridge classes. More...

#include <Partridge_All.h>

Inheritance diagram for Partridge_Base:
TAnimal TALMaSSObject Partridge_Chick Partridge_Clutch Partridge_Female Partridge_Male Partridge_Chick2

Public Member Functions

Partridge_Object GetObjectType ()
 Supply object type. More...
bool GetUncleStatus ()
 Supply uncle status. More...
void SetUncleStatus (bool a_Status)
 Set uncle status. More...
bool PossibleMate (Partridge_Base *a_partridge)
 Can we mate? More...
virtual bool ArePaired ()
 Overridden base function. More...
Partridge_CoveyGetCovey (void)
 Supply covey pointer. More...
Partridge_State GetState (void)
 Supply state. More...
void SetState (Partridge_State a_pars)
 Set state. More...
int GetFamily (void)
 Supply family ID. More...
int GetAge (void)
 Supply age. More...
void SetAge (int a_age)
 Set age. More...
long GetID (void)
 Supply ID. More...
void SetFamily (unsigned int family)
 Set family ID. More...
void SetCovey (Partridge_Covey *a_covey)
 Set covey pointer. More...
void MakeCovey ()
 Create our own covey. More...
void SwitchCovey (Partridge_Covey *a_covey)
 Swap coveys. More...
 Partridge_Base (int a_born_x, int a_born_y, int a_x, int a_y, int a_family_counter, Partridge_Covey *a_covey, Landscape *a_map, Partridge_Population_Manager *a_manager)
 Constructor for Partridge_Base. More...
virtual ~Partridge_Base (void)
 Destructor. More...
virtual void CopyMyself (int a_Ptype)
 Duplicate this object. More...
- Public Member Functions inherited from TAnimal
unsigned SupplyFarmOwnerRef ()
AnimalPosition SupplyPosition ()
APoint SupplyPoint ()
int SupplyPolygonRef ()
int Supply_m_Location_x ()
int Supply_m_Location_y ()
virtual void KillThis ()
virtual void CopyMyself ()
void SetX (int a_x)
void SetY (int a_y)
 TAnimal (int x, int y, Landscape *L)
virtual void BeginStep (void)
 BeingStep behaviour - must be implemented in descendent classes. More...
virtual void Step (void)
 Step behaviour - must be implemented in descendent classes. More...
virtual void EndStep (void)
 EndStep behaviour - must be implemented in descendent classes. More...
virtual void ReinitialiseObject (int x, int y, Landscape *L)
 Used to re-use an object - must be implemented in descendent classes. More...
virtual int WhatState ()
virtual void Dying ()
void CheckManagement (void)
void CheckManagementXY (int x, int y)
virtual bool OnFarmEvent (FarmToDo)
- Public Member Functions inherited from TALMaSSObject
int GetCurrentStateNo ()
 Returns the current state number. More...
void SetCurrentStateNo (int a_num)
 Sets the current state number. More...
bool GetStepDone ()
 Returns the step done indicator flag. More...
void SetStepDone (bool a_bool)
 Sets the step done indicator flag. More...
virtual void ReinitialiseObject ()
 Used to re-use an object - must be implemented in descendent classes. More...
 TALMaSSObject ()
 The constructor for TALMaSSObject. More...
virtual ~TALMaSSObject ()
 The destructor for TALMaSSObject. More...
void OnArrayBoundsError ()
 Used for debugging only, tests basic object properties. More...

Public Attributes

 Pointer to the population manager. More...

Protected Member Functions

virtual bool DailyMortality ()
 Background mortality test. More...
virtual void CheckMatePointers ()
 Debug. More...
- Protected Member Functions inherited from TAnimal
void CorrectWrapRound ()
 Corrects wrap around co-ordinate problems. More...

Protected Attributes

int m_signal
 Used to pass information to outputs. More...
long m_id
 Individual bird ID. More...
int m_family_counter
 Family ID. More...
int m_age
 Age in days. More...
int m_born_x
 x-coord of birth More...
int m_born_y
 y-coord of birth More...
bool m_UncleStatus
 If has uncle status in the covey. More...
Partridge_Object m_object_type
 Type of pob object this is. More...
 Pointer to the covey. More...
Partridge_State m_state
 Current behavioural state. More...
- Protected Attributes inherited from TAnimal
int m_Location_x
int m_Location_y
- Protected Attributes inherited from TALMaSSObject
int m_CurrentStateNo
 The basic state number for all objects - '-1' indicates death. More...
bool m_StepDone
 Indicates whether the iterative step code is done for this timestep. More...

Detailed Description

Base class for all partridge classes.

Constructor & Destructor Documentation

◆ Partridge_Base()

Partridge_Base::Partridge_Base ( int  a_born_x,
int  a_born_y,
int  a_x,
int  a_y,
int  a_family_counter,
Partridge_Covey a_covey,
Landscape a_map,
Partridge_Population_Manager a_manager 

Constructor for Partridge_Base.

If a_flock is NULL, then assume this is an animal created during population manager initialization and that covey creation/addtion is controlled by the calling method.

157  : TAnimal( a_x, a_y, a_map )
158  {
159  m_age = 0;
160  m_born_x = a_born_x;
161  m_born_y = a_born_y;
162  m_UncleStatus = false;
163  m_family_counter = a_family_counter;
164  m_id = g_partridge_id++;
165  m_covey = a_covey;
166  // **CJT** NB it is the responsibility of the calling method
167  // to ensure that if a_covey is NULL, then the bird is added later
168  if ( m_covey ) m_covey->AddMember( this );
170  m_OurPopulationManager = a_manager;
171  m_signal = -9999; // used to trap non-set signal output
172 }
static long g_partridge_id
Definition: Partridge_All.cpp:151
@ pars_Initiation
Definition: Partridge_All.h:267
int m_age
Age in days.
Definition: Partridge_All.h:410
int m_born_x
x-coord of birth
Definition: Partridge_All.h:412
int m_born_y
y-coord of birth
Definition: Partridge_All.h:414
long m_id
Individual bird ID.
Definition: Partridge_All.h:406
Partridge_State m_state
Current behavioural state.
Definition: Partridge_All.h:422
Partridge_Covey * m_covey
Pointer to the covey.
Definition: Partridge_All.h:420
int m_family_counter
Family ID.
Definition: Partridge_All.h:408
bool m_UncleStatus
If has uncle status in the covey.
Definition: Partridge_All.h:416
int m_signal
Used to pass information to outputs.
Definition: Partridge_All.h:404
Partridge_Population_Manager * m_OurPopulationManager
Pointer to the population manager.
Definition: Partridge_All.h:430
void AddMember(Partridge_Base *a_new_member)
Definition: Partridge_Covey.cpp:1644
TAnimal(int x, int y, Landscape *L)
Definition: PopulationManager.cpp:1367

References Partridge_Covey::AddMember(), g_partridge_id, m_age, m_born_x, m_born_y, m_covey, m_family_counter, m_id, m_OurPopulationManager, m_signal, m_state, m_UncleStatus, and pars_Initiation.

◆ ~Partridge_Base()

Partridge_Base::~Partridge_Base ( void  )


The destructor removes an animal from its flock.

193 {
194  // Line removed because it causes all kinds of concurrency problems
195  // removal from covey must occur when the bird is killed, not later in the day
196  // m_covey->RemoveMember( this );
197 }

Member Function Documentation

◆ ArePaired()

virtual bool Partridge_Base::ArePaired ( )

Overridden base function.

Reimplemented in Partridge_Female, and Partridge_Male.

450 { return false; }

◆ CheckMatePointers()

virtual void Partridge_Base::CheckMatePointers ( )


Reimplemented in Partridge_Female, and Partridge_Male.

426 {;}

Referenced by Partridge_Clutch::Step().

◆ CopyMyself()

void Partridge_Base::CopyMyself ( int  a_Ptype)

Duplicate this object.

A method required only for experimental manipulations - e.g. sudden doubling of population size.

239  {
240  AdultPartridge_struct * aps;
241  aps = new AdultPartridge_struct;
242  aps->bx = m_born_x;
243  aps->by = m_born_y;
244  aps->x = m_Location_x;
245  aps->y = m_Location_y;
246  aps->L = m_OurLandscape;
247  aps->family_counter = random(1000000);
248  aps->age = m_age;
249  if (a_Ptype==pob_Male) {
250  aps->sex=true;
251  } else {
252  aps->sex=false;
253  }
255  delete aps;
256 }
int random(int a_range)
Definition: ALMaSS_CmdLine.cpp:142
@ pob_Male
Definition: Partridge_All.h:297
Struct to pass adult partridge information.
Definition: Partridge_All.h:386
int age
Definition: Partridge_All.h:389
bool sex
Definition: Partridge_All.h:388
void CreateCloneObjects(int ob_type, AdultPartridge_struct *as)
Definition: Partridge_Population_Manager.cpp:535
int by
Definition: Partridge_All.h:347
int x
Definition: Partridge_All.h:344
int bx
Definition: Partridge_All.h:346
int y
Definition: Partridge_All.h:345
Landscape * L
Definition: Partridge_All.h:348
int family_counter
Definition: Partridge_All.h:350
int m_Location_y
Definition: PopulationManager.h:228
int m_Location_x
Definition: PopulationManager.h:225
Landscape * m_OurLandscape
Definition: PopulationManager.h:229

References AdultPartridge_struct::age, Partridge_struct::bx, Partridge_struct::by, Partridge_Population_Manager::CreateCloneObjects(), Partridge_struct::family_counter, Partridge_struct::L, m_age, m_born_x, m_born_y, TAnimal::m_Location_x, TAnimal::m_Location_y, TAnimal::m_OurLandscape, m_OurPopulationManager, pob_Male, random(), AdultPartridge_struct::sex, Partridge_struct::x, and Partridge_struct::y.

Referenced by Partridge_Population_Manager::Catastrophe(), and Partridge_Population_Manager::MaleImmigration().

◆ DailyMortality()

bool Partridge_Base::DailyMortality ( void  )

Background mortality test.

This should not really be used.

Reimplemented in Partridge_Female, Partridge_Male, Partridge_Chick2, Partridge_Chick, and Partridge_Clutch.

229 {
230  int chance = random( 100000 );
231  if ( chance < cfg_par_base_mortality.value() ) return true;
232  return false;
233 }
static CfgInt cfg_par_base_mortality("PAR_BASE_MORTALITY", CFG_CUSTOM, 0)
int value(void)
Definition: configurator.h:98

References cfg_par_base_mortality, random(), and CfgInt::value().

◆ GetAge()

int Partridge_Base::GetAge ( void  )

Supply age.

472  {
473  return m_age;
474  }

References m_age.

Referenced by Partridge_Population_Manager::DoFirst(), and Partridge_Covey::SupplyChickAge().

◆ GetCovey()

Partridge_Covey* Partridge_Base::GetCovey ( void  )

Supply covey pointer.

453  {
454  return m_covey;
455  }

References m_covey.

Referenced by Partridge_Population_Manager::DissolveCovey().

◆ GetFamily()

int Partridge_Base::GetFamily ( void  )

◆ GetID()

long Partridge_Base::GetID ( void  )

Supply ID.

482  {
483  return m_id;
484  }

References m_id.

Referenced by Partridge_Covey::RemoveMember().

◆ GetObjectType()

Partridge_Object Partridge_Base::GetObjectType ( )

Supply object type.

432  {
433  return m_object_type;
434  }
Partridge_Object m_object_type
Type of pob object this is.
Definition: Partridge_All.h:418

References m_object_type.

Referenced by Partridge_Population_Manager::DissolveCovey(), Partridge_Covey::FindMeAHusband(), Partridge_Covey::FindMeAWife(), and Partridge_Communication::PassMessage().

◆ GetState()

Partridge_State Partridge_Base::GetState ( void  )

Supply state.

457  {
458  return m_state;
459  }

References m_state.

◆ GetUncleStatus()

bool Partridge_Base::GetUncleStatus ( )

Supply uncle status.

437  {
438  return m_UncleStatus;
439  }

References m_UncleStatus.

Referenced by Partridge_Population_Manager::DissolveCovey().

◆ MakeCovey()

void Partridge_Base::MakeCovey ( void  )

Create our own covey.

Only called when a bird must make a new covey the bird will be the first member and the only one on calling. NB all housekeeping in the population manager is handled by the Covey constructor. The caller is responsible for removing the bird from the present covey before this call is made (or immediately after).

207 {
209 }
The collective for a family of partridges
Definition: Partridge_Covey.h:90

References m_covey, TAnimal::m_Location_x, TAnimal::m_Location_y, TAnimal::m_OurLandscape, and m_OurPopulationManager.

Referenced by Partridge_Population_Manager::DissolveCovey(), and Partridge_Male::MFindingMate().

◆ PossibleMate()

bool Partridge_Base::PossibleMate ( Partridge_Base a_partridge)

Can we mate?

Checks whether the supplied bird is a potential mate, or is too closely related.

180 {
181  if ( ( a_partridge->GetFamily() < m_family_counter - 1 || a_partridge->GetFamily() > m_family_counter + 1 )
182  // Possible age check?
183  )
184  {
185  return true;
186  }
187  return false;
188 }
int GetFamily(void)
Supply family ID.
Definition: Partridge_All.h:467

References GetFamily(), and m_family_counter.

◆ SetAge()

void Partridge_Base::SetAge ( int  a_age)

Set age.

477  {
478  m_age = a_age;
479  }

References m_age.

Referenced by Partridge_Population_Manager::CreateCloneObjects().

◆ SetCovey()

void Partridge_Base::SetCovey ( Partridge_Covey a_covey)

◆ SetFamily()

void Partridge_Base::SetFamily ( unsigned int  family)

Set family ID.

487  {
488  m_family_counter = family;
489  }

References m_family_counter.

Referenced by Partridge_Male::OnMating().

◆ SetState()

void Partridge_Base::SetState ( Partridge_State  a_pars)

Set state.

462  {
463  m_state = a_pars;
464  }

References m_state.

Referenced by Partridge_Population_Manager::Catastrophe(), and Partridge_Covey::SetUncle().

◆ SetUncleStatus()

void Partridge_Base::SetUncleStatus ( bool  a_Status)

◆ SwitchCovey()

void Partridge_Base::SwitchCovey ( Partridge_Covey a_covey)

Swap coveys.

Moves the bird from its cuurent covey to the one supplied.

217 {
218  m_covey->RemoveMember( this );
219  m_covey = a_covey;
220  m_covey->AddMember( this );
221 }
int RemoveMember(Partridge_Base *a_former_member)
Remove a member from the covey.
Definition: Partridge_Covey.cpp:1664

References Partridge_Covey::AddMember(), m_covey, and Partridge_Covey::RemoveMember().

Referenced by Partridge_Female::OnMating().

Member Data Documentation

◆ m_age

◆ m_born_x

int Partridge_Base::m_born_x

x-coord of birth

Referenced by Partridge_Chick2::ChMaturing(), CopyMyself(), and Partridge_Base().

◆ m_born_y

int Partridge_Base::m_born_y

y-coord of birth

Referenced by Partridge_Chick2::ChMaturing(), CopyMyself(), and Partridge_Base().

◆ m_covey

◆ m_family_counter

◆ m_id

long Partridge_Base::m_id

Individual bird ID.

Referenced by GetID(), and Partridge_Base().

◆ m_object_type

◆ m_OurPopulationManager

◆ m_signal

int Partridge_Base::m_signal

◆ m_state

◆ m_UncleStatus

bool Partridge_Base::m_UncleStatus

The documentation for this class was generated from the following files: